var o = getApp();

Page({
    data: {
        Height: "",
        tempshare: null,
        username: "用户昵称",
        signName: "个性签名",
        category: [],
        carousel: [],
        goodsListData: [],
        ads: [],
        bannerData: [],
        userImg: "",
        shop_logo: "",
        shop_name: "",
        shop_id: "",
        bgImg: "",
        isCategory: !1,
        amout: !0,
        index2: 1,
        other: "",
        content: "",
        show: !0,
        tempData: [ {
            id: "M1491471961972",
            temp: "showsearch",
            params: {
                placeholder: "",
                style: "style2",
                color: "#000",
                bgcolor: "#FFF",
                bordercolor: "#fa1f24",
                searchurl: "",
                uniacid: "6"
            },
            data: "",
            other: "",
            content: ""
        } ],
        oftemp: !1,
        dftempData: !1,
        follow: !1,
        isfollow: !0,
        havaShop: !1,
        shopData: {},
        iPnoneBottomBol: !1,
        isLoadMore: !0,
        page: 1,
        total_page: 0
    },
    onLoad: function(t) {
        this.getiPnoneBottom(), t.mid && o._setMid(t.mid), t.shop_id && (this.setData({
            shop_id: t.shop_id
        }), o._setshopid(t.shop_id)), this.getMicroShop();
    },
    getiPnoneBottom: function() {
        try {
            wx.getStorageSync("iPhoneBottom") && this.setData({
                iPnoneBottomBol: !0
            });
        } catch (o) {}
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多了");
    },
    getMoreData: function() {
        var t = this;
        if (this.setData({
            isLoadMore: !1
        }), !(this.data.page >= this.data.total_page)) {
            var a = this.data.page + 1;
            this.setData({
                page: a
            });
            var e = o.getNetAddresss("plugin.micro.frontend.controllers.MicroShop.MicroShopByShare.get-goods");
            e += "&page=" + this.data.page, e += "&shop_id=" + this.data.shop_id, o._getNetWork({
                url: e,
                success: function(o) {
                    var a = o.data;
                    if (1 == a.result) {
                        var e = a.data.goods_list.data;
                        t.data.isLoadMore = !0, t.setData({
                            goodsListData: t.data.goodsListData.concat(e)
                        });
                    } else t.data.page = t.data.page - 1, t.data.isLoadMore = !1;
                },
                fail: function(o) {
                    console.log(o);
                }
            });
        }
    },
    onShareTimeline: function() {
        if (this.data.shop_id) {
            var o = wx.getStorageSync("yz_uid"), t = "";
            return o && (t = o), {
                query: "shop_id=" + this.data.shop_id + "&mid=" + t
            };
        }
        wx.showToast({
            title: "分享信息正在加载",
            icon: "none",
            duration: 1500
        });
    },
    onShareAppMessage: function(o) {
        if (o && "menu" === o.from) {
            if (this.data.shop_id) {
                var t = wx.getStorageSync("yz_uid"), a = "";
                return t && (a = t), {
                    path: "/packageC/microshop/micro_shop_share_home/micro_shop_share_home?shop_id=" + this.data.shop_id + "&mid=" + a
                };
            }
            wx.showToast({
                title: "分享信息正在加载",
                icon: "none",
                duration: 1500
            });
        }
    },
    getMicroShop: function() {
        var t = this;
        t.data.isLoadMore = !1;
        var a = o.getNetAddresss("plugin.micro.frontend.controllers.MicroShop.MicroShopByShare");
        o._getNetWork({
            url: a,
            data: {
                shop_id: t.data.shop_id ? Number(t.data.shop_id) : null
            },
            success: function(o) {
                var a = o.data;
                1 == a.result ? (t.setData({
                    isLoadMore: !0,
                    shopData: a.data
                }), t.setMicroShopUserInfo(a.data), t.setBannerData(a.data), t.setCategoryData(a.data), 
                t.setIsMicroShop(a.data), t.getGoodList()) : wx.showToast({
                    title: a.msg,
                    icon: "none",
                    duration: 1500
                });
            },
            fail: function(o) {
                console.log(o);
            }
        });
    },
    getGoodList: function() {
        var t = this, a = o.getNetAddresss("plugin.micro.frontend.controllers.MicroShop.MicroShopByShare.get-goods");
        a += "&shop_id=" + this.data.shop_id, o._postNetWork({
            url: a,
            data: {},
            success: function(o) {
                var a = o.data;
                1 == a.result ? t.setGoodsData(a) : wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1e3
                });
            },
            fail: function(o) {
                console.log(o);
            }
        });
    },
    setMicroShopUserInfo: function(o) {
        this.setData({
            username: o.nickname,
            signName: o.signature,
            shop_logo: o.shop_logo,
            shop_name: o.shop_name,
            bgImg: 0 != o.shop_background && o.shop_background,
            userImg: o.shop_avatar
        }), wx.setNavigationBarTitle({
            title: this.data.username
        });
    },
    setBannerData: function(o) {
        this.setData({
            bannerData: o.carousel
        });
    },
    setCategoryData: function(t) {
        if (o._isTextEmpty(t.category) || 0 == t.category.length) this.setData({
            isCategory: !1
        }); else {
            this.setData({
                isCategory: !0
            });
            this.setData({
                category: this.chunk(t.category, 8)
            });
        }
    },
    setGoodsData: function(o) {
        this.setData({
            goodsListData: o.data.goods_list.data
        }), this.data.total_page = o.data.goods_list.last_page, this.data.page = o.data.goods_list.current_page;
    },
    setIsMicroShop: function(o) {
        this.setData({
            is_micro_shop: o.is_micro_shop
        });
    },
    imgHeight: function(o) {
        var t = wx.getSystemInfoSync().windowWidth * o.detail.height / o.detail.width + "px";
        this.setData({
            Height: t
        });
    },
    gomicroShop_apply: function() {
        wx.navigateTo({
            url: "/packageC/microshop/microShop_apply/microShop_apply"
        });
    },
    gomicroShopShopKeeperCenter: function() {
        wx.navigateTo({
            url: "/packageC/microshop/microShop_ShopKeeperCenter/microShop_ShopKeeperCenter?shop_id=" + this.data.shop_id
        });
    },
    goimgurl: function(o) {},
    gohome: function() {
        wx.reLaunch({
            url: "/packageG/index/index"
        });
    },
    gocart: function() {
        wx.reLaunch({
            url: "/packageG/pages/buy/cart_v2/cart_v2"
        });
    },
    gomember: function() {
        wx.reLaunch({
            url: "/packageG/member_v2/member_v2"
        });
    },
    gomicroShopShareCategory: function() {
        wx.navigateTo({
            url: "/packageC/microshop/micro_shop_share_category/micro_shop_share_category?shop_id=" + this.data.shop_id
        });
    },
    chunk: function(o, t) {
        for (var a = [], e = 0, s = o.length; e < s; e += t) a.push(o.slice(e, e + t));
        return a;
    }
});